package com.tubruk.object.option;

import java.util.ArrayList;

import com.tubruk.object.ConstantList;
import com.tubruk.object.Option;

public class ListOption extends Option {

	ArrayList<ConstantList> allowable;
	
	public ArrayList<ConstantList> getAllowableValues(){
		return allowable;
	}
	
	public void setAllowableValues(ArrayList<ConstantList> allowable){
		this.allowable = allowable;
	}
	
	public int findSelectedIndex(){
		int result = 0;
		
		int size = allowable.size();
		
		for (int i=0;i<size;i++){
			ConstantList constant = allowable.get(i);
			if (Integer.parseInt(this.getValue()) == constant.getId()){
				result = i;
				i = size;
			}
		}
		
		return result;
	}
}
